Skip to content

Fix/skip unlimited output size accounting - #1371

Open
vadipp wants to merge 3 commits into
HubSpot:masterfrom
vadipp:fix/skip-unlimited-output-size-accounting
Open

vadipp wants to merge 3 commits into
HubSpot:masterfrom
vadipp:fix/skip-unlimited-output-size-accounting

Conversation

@vadipp

@vadipp vadipp commented Nov 24, 2026 •

Copy link
Copy Markdown

With the default maxOutputSize = 0 (unlimited), OutputList.addNode still calls getSize() to update currentSize. RenderedOutputNode.getSize() encodes each fragment as UTF-8 and discards the resulting byte array, adding allocation and encoding work on every render, including when the parsed template is cached.

This change skips both size-accounting steps when maxOutputSize <= 0. Nodes are still appended and block placeholders are still registered for later resolution. Positive-limit accounting and exception behavior, including the additional resolved-block accounting, are preserved.

Validation

Eight regression tests cover:

  • No getSize() calls for ordinary nodes or block placeholders with zero and negative limits.
  • UTF-8 byte boundaries for ASCII, Cyrillic and emoji, including accumulated sizes across nodes.
  • Existing positive-limit exception messages and resolved-block handling.
  • HTML rendering with variables, loops, blocks and inheritance.

The same accounting path also exists in Jinjava 2.7.3 and 2.8.5; maintenance-branch backports can be considered separately.

Disclaimer: implemented by Codex, verified by human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant